package com.bmob.lover.data.model.bean

import android.os.Parcelable
import com.google.gson.annotations.SerializedName
import com.luck.picture.lib.config.SelectMimeType
import com.theone.common.callback.IImageUrl
import kotlinx.parcelize.Parcelize

//  ┏┓　　　┏┓
//┏┛┻━━━┛┻┓
//┃　　　　　　　┃
//┃　　　━　　　┃
//┃　┳┛　┗┳　┃
//┃　　　　　　　┃
//┃　　　┻　　　┃
//┃　　　　　　　┃
//┗━┓　　　┏━┛
//    ┃　　　┃                  神兽保佑
//    ┃　　　┃                  永无BUG！
//    ┃　　　┗━━━┓
//    ┃　　　　　　　┣┓
//    ┃　　　　　　　┏┛
//    ┗┓┓┏━┳┓┏┛
//      ┃┫┫　┃┫┫
//      ┗┻┛　┗┻┛
/**
 * @author The one
 * @date 2021-04-22 15:26
 * @describe TODO
 * @email 625805189@qq.com
 * @remark
 */
@Parcelize
data class TheFile(
    var path: String = "",
    @SerializedName("thumbnail")
    var mThumbnail: String = "",
    @SerializedName("width")
    var mWidth: Int = 0,
    @SerializedName("height")
    var mHeight: Int = 0,
    @SerializedName("size")
    var mSize: Long = 0,
    var thumbnailSize: Long = 0,
    var localPath: String = "",
    @SerializedName("fileName")
    var mFileName: String = "",
    var type:Int = 0
) :IImageUrl, Parcelable {

    override fun getImageUrl(): String = path

    override fun resType(): IImageUrl.Type =
        if (type == SelectMimeType.TYPE_VIDEO) IImageUrl.Type.VIDEO else IImageUrl.Type.IMAGE

    override fun getHeight(): Int = mHeight

    override fun getThumbnail(): String? = if (mThumbnail.isNotEmpty()) mThumbnail else path

    override fun getRefer(): String = ""

    override fun getWidth(): Int = mWidth

    override fun toString(): String {
        return "TheFile(path='$path', mThumbnail='$mThumbnail', mWidth=$mWidth, mHeight=$mHeight, size=$mSize, localPath='$localPath', fileName='$mFileName', type=$type)"
    }

    override fun setWidth(size: Int) {
        mWidth = size
    }

    override fun setHeight(size: Int) {
        mHeight = size
    }

    override fun equals(other: Any?): Boolean {
        if (other is TheFile) {
            other.let {
                return it.path == path && it.mThumbnail == mThumbnail && it.type == type
            }
        }
        return false
    }

}
